<template>
  <div style="width: 100%;height: 100%;overflow: hidden;">

    <div style="position: fixed;left: 0;right: 0;top: 0;bottom: 0;overflow: auto;" class="_wz_pcHome">
<!--        <div style="position: absolute;top: 0px;left: 0px;right: 0px;bottom: 0px;z-index: 99;height:100%;" @click="$toast('更多精彩 敬请期待');"></div>-->
        <div class="_wz_pcHome_conent">
          <img src="../../assets1/er/pc/indxTop.png" style="width: 100%;">

          <div style="height: 260px;display: flex;align-items: center;justify-content: center;">
<!--            会议简介-->
            <img src="../../assets1/er/pc/an1.png" @click="enter('day')" style="width: 180px;cursor: pointer;">
<!--            会议须知-->
            <img src="../../assets1/er/pc/an2.png" @click="enter('know')" style="width: 180px;cursor: pointer;">
<!--            线上展厅-->
            <img src="../../assets1/er/pc/an3.png" @click="enter('onlineExhibitionHall')" style="width: 180px;cursor: pointer;">
<!--            会议直播-->
            <img src="../../assets1/er/pc/an4.png" @click="enter('pcliveList')" style="width: 180px;cursor: pointer;">
          </div>

        </div>

    </div>

    <peoplePopup ref="peoplePopup" @checkUser="checkUser"></peoplePopup>
  </div>
</template>
<script>
import peoplePopup from "@/components/peoplePopup.vue";
import wxApi from "@/utils/wxapi.js";
import returnIndex from "@/components/return";
export default {
  components: {
    peoplePopup,
  },
  data() {
    return {
      userData:{},
    }
  },
  computed: {//计算属性

  },
  beforeCreate() {//beforeCreate创建前状态

  },
  created() {//created创建完毕状态

  },
  beforeMount() {//beforeMount挂载前状态   DOM 元素然后塞入页面的过程

  },
  mounted() {//mounted 挂载结束状态
    let that = this;
    wxApi("", "", "https://prod.sumaokeji.com/h5/meeting/#/");

    //TODO
    // localStorage.clear();
    //判断用户是否登录
    if (!localStorage.getItem("userId")) {
      that.$refs.peoplePopup.open(that.$store.state.isMobile);
    } else {
      that.checkUser();
    }

    that.resize();
    window.addEventListener('resize', () => {
      that.resize();
    }, false)
  },
  methods: {//执行的方法
    enter(flag, type) {
      let that = this;
      if (flag == "pclive") {
        that.pushPage(`${flag}`, { type: type });
      } else {
        that.pushPage(`${flag}`);
      }
    },
    //检验用户是否过期
    checkUser() {
      let that = this;
      that.$toast.loading({message: "加载中...", forbidClick: true});
      that.http.checkUserId({userId: localStorage.getItem("userId")}).then(res => {
        that.$toast.clear();
        if (res.status == 1103) {
          that.$refs.peoplePopup.open(that.$store.state.isMobile);
          // that.$that.$toast("登录已过期，请重新登录");
        }else{
          if (res.status == 1000) {
            if(!!res.data){
              localStorage.setItem("userId", res.data.userId);
              localStorage.setItem("userData", JSON.stringify(res.data));
              that.userData = res.data;
            }else{
              that.userData = {};
              that.$refs.peoplePopup.open(that.$store.state.isMobile);
              that.clearCache()
            }
          }
        }
      }).catch(err => {
        that.$toast.clear();
      });
    },
    clearCache(){
      localStorage.clear();
    },
    resize() {
      // PC 端首页
      if(document.getElementsByClassName('_wz_pcHome').length > 0){
        console.log('PC 端首页')
        var s = window.innerWidth / 1920;
        localStorage.setItem('multiple',s.toString())
        // document.body.style.zoom = s;//1 - s + 1;
        var home = document.getElementsByClassName('_wz_pcHome')[0]
        home.style.transformOrigin = '0 0';
        home.style.transform = 'scale(' + s + ',' + s + ')';
        home.style.width = window.innerWidth / s + 'px';
        home.style.height = window.innerHeight / s + 'px';
      }
    },
  },
  watch: {//监听

  },
  props: {//接收来自父组件的数据

  },
  beforeUpdate() {//beforeUpdate 更新前状态

  },
  updated() {//updated 更新完成状态

  },
  beforeDestroy() {//beforeDestroy 销毁前状态

  },
  destroyed() {//destroyed 销毁完成状态

  }
}
</script>

<style lang="scss">
._wz_pcHome_conent {
  background-image: url(../../assets1/er/pc/hyIndex.png);

  background-size: cover;
  background-position: center;
  height: 100%;
  overflow: auto;

}
</style>
